<template>
  <div class="hello">
    <!-- 子模板里的所有内容都是在子作用域中编译的。 -->
    <!-- <slot></slot> -->
    <slot :msg="msg">
      <span>before</span>
    </slot>
    <h1>{{ msg }}</h1>
    <!-- 插槽 prop -->
    <slot :user="user" :heading="msg" name="user"></slot>
    <hr />
    <div style="border: 2px solid #000">
      <span>下面是第一个slot</span>
      <slot name="first"></slot>
    </div>
    <hr />
    <div style="border: 2px solid #00f">
      <span>下面是第二个slot</span>
      <slot name="second"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      user: {
        firstName: "zhao",
        lastName: "四",
      },
    };
  },
  props: {
    msg: {
      type: String,
      default: "默认的msg",
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
